<?php

       function PFBC_Load($class) {
    $file =  pluginpath."/PFBC/" . str_replace("_", DIRECTORY_SEPARATOR, $class) . ".php";
    if(is_file($file))
        include_once $file;
}
spl_autoload_register("PFBC_Load");
if(in_array("__autoload", spl_autoload_functions()))
spl_autoload_register("__autoload");


        function PFBC_Load_Plugins($class) {
   
                $file =  includepath."/" . str_replace("_", DIRECTORY_SEPARATOR, $class) . ".php";
                
                if(is_file($file))
                    include_once $file;
         }
spl_autoload_register("PFBC_Load_Plugins");
if(in_array("__autoload", spl_autoload_functions()))
spl_autoload_register("__autoload");

     
        class model  { 


           function __construct($db_exec="",$userdata=array(),$post='')
           {
             global $info,$memcache;
             
             
             if($_COOKIE['oauth'])
             {
             $this->userdata=$_COOKIE;
             }else
             {
             $this->userdata=array();
             }
             
             if(count($userdata))
             {
            $this->userdata =$userdata;
             
             }
            
           
             if($post)
             {
             
             $this->post=$post;
             }
             
             
             if($db_exec)
             {
             $this->db=$db_exec; 
             
             }else
             {
             $db_exec = new db_execute(); 
             $db_exec->set_host(db_host);
             $db_exec->set_user(db_user);
             $db_exec->set_pass(db_pass); 
             $db_exec->set_database(db_name);
             $this->db=$db_exec; 
             $this->db->get_connect();
             $this->close=1;

             if($_GET['oauth'])
             {
             
             $this->userdata=$this->getuserbyoauth($_GET['oauth']);
             if($this->userdata['userid'])
             {
             
                  
           foreach($this->userdata as $keyuser =>$valueuser)
           {
                   if("imgmid"==$keyuser)
                   {
                   
                        $imgarray=$this->getimagebyimgmid($valueuser);

                        setcookie("imguser",$imgarray['newpath'], $time, "/",$domain);
                        setcookie("width",$imgarray['width'], $time, "/",$domain);
                        setcookie("height",$imgarray['height'], $time, "/",$domain);
                        $this->userdata['imguser']=$imgarray['newpath'];
                        $this->userdata['width']=$imgarray['width'];
                        $this->userdata['height']=$imgarray['height'];
                   
                   }else if("simgmid"==$keyuser)
                   {
                        $imgarray=$this->getimagebyimgmid($valueuser);

                        setcookie("simguser",$imgarray['newpath'], $time, "/",$domain);
                        setcookie("thumbwidth",$imgarray['width'], $time, "/",$domain);
                        setcookie("thumbheight",$imgarray['height'], $time, "/",$domain);
                        $this->userdata['simguser']=$imgarray['newpath'];
                        $this->userdata['thumbwidth']=$imgarray['width'];
                        $this->userdata['thumbheight']=$imgarray['height'];
                   
                   
                   }
                   
                   
                       //$this->arraydata['data'][$keyuser]=$valueuser;
                       setcookie($keyuser,$valueuser, $time, "/",$domain);
              
           
           
           
           }
           
             
             $_COOKIE=$this->userdata;
             }
             
             
             }
             
             
             if($_POST['oauth'])
             {
             $this->userdata=$this->getuserbyoauth($_POST['oauth']);
             
             
             }
             
             } 
             
             $this->memcache=$memcache;
             
             
             //echo "1"."<br>";
             
             
               
             
             
             $this->info=$info;
             
             
             
             
           }
    
         
         
        
        }
?>
